﻿using Project_Maverick.Controller.Input;
using Project_Maverick.GameRoot;
using Project_Maverick.Screen.Common;
using Project_Maverick.Screen.GameScreen.Play.Map;
using Transformable_Engine_v2.Engine.Transformable_Math.Geometry;

namespace Project_Maverick.Screen.GameScreen.Loading
{
    public class Loading : DefaultMenu
    {
        public BaseMap[] Maps { get; private set; }
        public SpawnPoint[] SpawnPoints { get; private set; }

        public Map.MapNames MapName { get; private set; }

        public Loading(Map.MapNames mapName) : base(Background.Blue(), "LOADING", new TE_Vector2(18, 18))
        {
            CallMethod(1000, () => LoadMap(mapName));
        }

        void LoadMap(Map.MapNames mapName)
        {
            Maps = Map.LoadMaps(mapName);
            MapName = mapName;
            PlayerReady();
        }

        public override void ReceiveLocalInputPressed(PlayerInputCommand playerInputCommand)
        {
        }

        public override void ReceiveLocalInputReleased(PlayerInputCommand playerInputCommand)
        {
        }

        public void PlayerReady()
        {
            CallMethod(1000, AllPlayersReady);
        }

        public void AllPlayersReady()
        {
            ChangeScreen(ProjectMaverick.Screen.Play, true);
        }
    }
}